package com.bzyd.mp.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description TODO
 * @Author dangxianyue
 * @Date 2023/3/18 10:37
 */
public class ReturnUtil {

    public static Map<String, Object> returnObj(Integer code, String msg, Object data) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("msg", msg);
        map.put("data", data);
        return map;
    }

    public static Map<String, Object> ok() {
        return returnObj(200, "ok", null);
    }

    public static Map<String, Object> ok(Object data) {
        return returnObj(200, "成功！", data);
    }

    public static Map<String, Object> fail() {
        return returnObj(500, "fail", null);
    }

    public static Map<String, Object> fail(String msg) {
        return returnObj(500, msg, null);
    }

    public static Map<String, Object> fail(Integer code, String msg) {
        return returnObj(code, msg, null);
    }
}
